package bb.lanxing.mvvm.base;

import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModelStoreOwner;

import java.util.HashMap;

import kotlin.jvm.internal.Intrinsics;

public final class VMStoreKt {
    private static final HashMap<String, VMStore> vMStores = new HashMap<>();

    public static HashMap<String, VMStore> getVMStores() {
        return vMStores;
    }

    public static ViewModelStoreOwner getViewModelStoreByScope(LifecycleOwner lifecycleOwner, String scope) {
        VMStore vMStore;
        Intrinsics.checkNotNullParameter(lifecycleOwner, "lifecycleOwner");
        Intrinsics.checkNotNullParameter(scope, "scope");
        HashMap<String, VMStore> hashMap = vMStores;
        if (hashMap.keySet().contains(scope)) {
            VMStore vMStore2 = hashMap.get(scope);
            Intrinsics.checkNotNull(vMStore2);
            vMStore = vMStore2;
        } else {
            VMStore vMStore3 = new VMStore();
            hashMap.put(scope, vMStore3);
            vMStore = vMStore3;
        }
        vMStore.bindHost(lifecycleOwner);
        return vMStore;
    }
}